#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_exgr_prop.info <<'%EOF%'
   cc_exgr_prop
   ------------
   Molecule:         H2O in C1
   Wave Function:    CCS, CC2, CCSD / STO-3G
   Test Purpose:     Excited states first-order properties and
                     transition moments
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_exgr_prop.mol <<'%EOF%'
BASIS
STO-3G  
Properties of excited state
H2O in minimal basis
    2    0  X  Y      1.00D-15
        8.0   1    2    2    1
O     0.0000000000000000  0.0000000000000000 -0.1359422200000000       *
        1.0   2    1    1
H     0.0000000000000000  1.447614500000000   1.07875057000000         *
H     0.0000000000000000  -1.44761450000000   1.07875057000000         *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_exgr_prop.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRALS
.DIPLEN
.SECMOM
**WAVE FUNCTIONS
.CC
*SCF INPUT
.THRESH
7.0D-9
*CC INP
.NSYM
 1
.CCS
.CC2
.CCSD
.THRENR
 1.0D-11
.THRLEQ
 1.0D-07
.NSIMLE
 5
.PRINT
 6
*CCEXCI
.NCCEXCI
 1
.THREXC
 1.0D-05
*CCFOP
.NONREL
.DIPMOM
.SECMOM
*CCEXGR
.DIPOLE
.SECMOM
*CCLRSD
.DIPOLE
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_exgr_prop.check
cat >>cc_exgr_prop.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-74.9656569916" | wc -l`
CRIT2=`$GREP "Total MP2   energy:  *\-75.00556505" $log | wc -l`
CRIT3=`$GREP "Total CC2   energy:  *\-75.0057135(29|30)" $log | wc -l`
CRIT4=`$GREP "Total CCSD  energy:  *\-75.02150754" $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4` 
CTRL[1]=7
ERROR[1]="ENERGIES NOT CORRECT"

# CCS excitation energy for 1. state in symmetry 1
# ..  |    1   |     0.4486495  |      12.20838  |     98467.191  | 100.00  |
CRIT1=`$GREP "\|    1   \|     ( |0)\.4486...  \|      12\.2083.  \|     98467\....  \| 100\.00" $log | wc -l`
TEST[2]=`expr $CRIT1` 
CTRL[2]=1
ERROR[2]="CCS EXCITATION ENERGY IS NOT CORRECT"

# CC2 excitation energy for 1. state in symmetry 1
# ..  |    1   |     0.4382523  |      11.92546  |     96185.252  |  98.47  |
CRIT1=`$GREP "\|    1   \|     ( |0)\.43825..  \|      11\.9254.  \|     96185\....  \|  98\.47" $log | wc -l`
TEST[3]=`expr $CRIT1` 
CTRL[3]=1
ERROR[3]="CC2 EXCITATION ENERGY IS NOT CORRECT"

# CCSD excitation energy for 1. state in symmetry 1
# ..  |    1   |     0.4199847  |      11.42837  |     92175.984  |  94.29  |
CRIT1=`$GREP "\|    1   \|     ( |0)\.41998..  \|      11\.4283.  \|     92175\....  \|  94\.29" $log | wc -l`
TEST[4]=`expr $CRIT1` 
CTRL[4]=1
ERROR[4]="CCSD EXCITATION ENERGY IS NOT CORRECT"

# CCS oscillator strengths for 1. state in symmetry 1
# ..  |    1   |        0.0094897      |      0.0028384       |    X        |
CRIT1=`$GREP "\|    1   \|        ( |0)\.0094...      \|      ( |0)\.002838.       \|    X        \|" $log | wc -l`
TEST[5]=`expr $CRIT1`
CTRL[5]=1
ERROR[5]="CCS OSCILLATOR STRENGTH IS NOT CORRECT"

# CC2 oscillator strengths for 1. state in symmetry 1
# ..  |    1   |        0.0091769      |      0.0026812       |    X        |
CRIT1=`$GREP "\|    1   \|        ( |0)\.00917..      \|      ( |0)\.002681.       \|    X        \|" $log | wc -l`
TEST[6]=`expr $CRIT1`
CTRL[6]=1
ERROR[6]="CC2 OSCILLATOR STRENGTH IS NOT CORRECT"

# CCSD oscillator strengths for 1. state in symmetry 1
# ..  |    1   |        0.0092361      |      0.0025860       |    X        |
CRIT1=`$GREP "\|    1   \|        ( |0)\.009236.      \|      ( |0)\.002586.       \|    X        \|" $log | wc -l`
TEST[7]=`expr $CRIT1`
CTRL[7]=1
ERROR[7]="CCSD OSCILLATOR STRENGTH IS NOT CORRECT"

# CCS excited state dipole moment for 1 state in symmetry 1
# z     -0.14163648        -0.36000398        -1.20084403
CRIT1=`$GREP "( -|-0)\.141636.. * ( -|-0).36000(39|40). * \-1\.20084[3-4].." $log | wc -l`
TEST[8]=`expr $CRIT1`
CTRL[8]=1
ERROR[8]="CCS EXCITED STATE DIPOLE MOMENT IS NOT CORRECT"

# CC2 excited state dipole moment for 1 state in symmetry 1
# z     -0.07521183        -0.19116938        -0.63767241
CRIT1=`$GREP "( -|-0)\.075211.. * ( -|-0)\.191169.. * ( -|-0)\.637672.." $log | wc -l`
TEST[9]=`expr $CRIT1`
CTRL[9]=1
ERROR[9]="CC2 EXCITED STATE DIPOLE MOMENT IS NOT CORRECT"

# CCSD excited state dipole moment for 1 state in symmetry 1
# z     -0.03598914        -0.09147526        -0.30512862
CRIT1=`$GREP "( -|-0)\.035989.. * ( -|-0)\.091475.. * ( -|-0)\.3051(2|3)..." $log | wc -l`
TEST[10]=`expr $CRIT1`
CTRL[10]=1
ERROR[10]="CCSD EXCITED STATE DIPOLE MOMENT IS NOT CORRECT"

# CCS excited state SECOND MOMENTS for 1 state in symmetry 1
# Property anisotropy invariant:              4.382795 a.u.
CRIT1=`$GREP "Property anisotropy invariant:  * 4.38279. a\.u\." $log | wc -l`
TEST[11]=`expr $CRIT1`
CTRL[11]=1
ERROR[11]="CCS EXCITED STATE SECOND MOMENTS ARE NOT CORRECT"


# CC2 excited state SECOND MOMENTS for 1 state in symmetry 1
# Property anisotropy invariant:              4.276446 a.u.
CRIT1=`$GREP "Property anisotropy invariant:  * 4.27644. a\.u\." $log | wc -l`
TEST[12]=`expr $CRIT1`
CTRL[12]=1
ERROR[12]="CC2 EXCITED STATE SECOND MOMENTS ARE NOT CORRECT"


# CCSD excited state SECOND MOMENTS for 1 state in symmetry 1
# Property anisotropy invariant:              4.220926 a.u.
CRIT1=`$GREP "Property anisotropy invariant:  * 4.22092. a\.u\." $log | wc -l`
TEST[13]=`expr $CRIT1`
CTRL[13]=1
ERROR[13]="CCSD EXCITED STATE SECOND MOMENTS ARE NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
